const db = wx.cloud.database()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    oldlist:"",
    loading:true
  },
  onLoad: function (options) {
    this.onShow()
  },
  onShow: function () {
    this.getList()
  },

  // 根据删除老人
delete(e){
    console.log(e.currentTarget.dataset.id)
    wx.cloud.callFunction({
      name:"Oldman",
      data:{
        type:"delete",
        id:e.currentTarget.dataset.id
      }
    }).then(res=>{
      wx.showToast({
        title: '删除成功'
      })
      this.getList()
    })
},

  getList(){
      wx.cloud.callFunction({
        name:"getOldList"
      }).then(res=>{
        console.log(res)
      this.setData({
        oldlist:res.result.data,
        loading:false
      })
      })
  },
  toAdd(){
    wx.navigateTo({
      url: '../addman/addman',
    })
  },
  toHealth(e){
    wx.navigateTo({
      url: '../health/health?id='+e.currentTarget.dataset.id,
    })
  }
  
})



  


  

  